
import random

class CoinsGuess:
    #random two numbers between 0.8 to 0.9    
    def __init__(self):
        random.seed()
        self.p1 = random.random()
        self.p2 = random.random()
        self.p1 = self.p1/10.0 + 0.8
        self.p2 = self.p2/10.0 + 0.8
        self.count1 = 0
        self.count2 = 0
        
    # gets the number of tosses, for each toss decide head or tail according to
    # the probability. At the end it calculates the avg result for all the tosses
    def run(self, tosses):
        iterate = tosses
        self.count1 = 0
        self.count2 = 0
        self.avg1 = 0
        self.avg2 = 0
        while (iterate > 0):
            resA = random.random()
            resB = random.random()
            if (resA < self.p1):
                self.count1 = self.count1 + 1
            if (resB < self.p2):
                self.count2 = self.count2 + 1            
            iterate = iterate - 1
        self.avg1 = self.count1/float(tosses)
        self.avg2 = self.count2/float(tosses)
        